package io.renren.modules.bindinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.alarmonline.entity.AreaalarmOnlineEntity;
import io.renren.modules.weldingmachineinfo.entity.WeldingmachineinfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.bindinfo.entity.BindinfoEntity;
import io.renren.modules.bindinfo.service.BindinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-01-01 19:53:07
 */
@RestController
@RequestMapping("bindinfo/bindinfo")
public class BindinfoController {
    @Autowired
    private BindinfoService bindinfoService;


    @GetMapping("getbindinfo")
    public List<BindinfoEntity> getbindinfo(@RequestParam(value = "wmId",required = false) String wmId, @RequestParam(value = "normId",required = false) String normId){
        return bindinfoService.getbindinfo(wmId,normId);
    }

    /**
     * 确认绑定
     */
    @PostMapping(value = "/add",produces = {"application/json;charset=UTF-8"})
    public void insertItem(@RequestParam(value = "wmId",required = false) String wmId,@RequestParam(value = "normId",required = false) String normId,@RequestParam(value = "startTime",required = false) String startTime,@RequestParam(value = "endTime",required = false) String endTime){
        bindinfoService.insertItem(wmId,normId,startTime,endTime);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bindinfo:bindinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bindinfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bindid}")
    @RequiresPermissions("bindinfo:bindinfo:info")
    public R info(@PathVariable("bindid") Integer bindid){
		BindinfoEntity bindinfo = bindinfoService.getById(bindid);

        return R.ok().put("bindinfo", bindinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bindinfo:bindinfo:save")
    public R save(@RequestBody BindinfoEntity bindinfo){
		bindinfoService.save(bindinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bindinfo:bindinfo:update")
    public R update(@RequestBody BindinfoEntity bindinfo){
		bindinfoService.updateById(bindinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bindinfo:bindinfo:delete")
    public R delete(@RequestBody Integer[] bindids){
		bindinfoService.removeByIds(Arrays.asList(bindids));

        return R.ok();
    }

}
